home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / C++ Direct Buffer Access Code / Blitting.sit / Blitting Folder ƒ / MySprite ƒ / ForegroundObject.h < prev    next >
Text File  |  1995-08-04  |  1KB  |  55 lines

  1. // ForegroundObject.h, any moving object on the screen is a foreground object.
  2. //    If you move a ForegroundObject, getOldRect will return where the sprite
  3. //    used to be (it would be wise to erase that area). getRect will return where
  4. //    the new object has been drawn or will be drawn (it would be wise to use this
  5. //    if you wanted to copy that rectangle). getOldAndNew will return a union of
  6. //    the old and new rectangles.
  7.  
  8. // copyright ⌐ 1995, Macneil Shonle. All rights reserved.
  9.  
  10. #ifndef __FOREGROUNDOBJECT__
  11. #define __FOREGROUNDOBJECT__
  12.  
  13. #ifndef __BUFFERACCESSOR__
  14. #include <BufferAccessor.h>
  15. #endif
  16.  
  17. #ifndef __SPRITE__
  18. #include <Sprite.h>
  19. #endif
  20.  
  21.         // class ForegroundObject
  22. class ForegroundObject {
  23. public:
  24.     virtual ~ForegroundObject() {}
  25.     virtual void draw(BufferAccessor&) const = 0;
  26.     virtual void move(BufferAccessor&) = 0;
  27.     virtual Rect& getOldRect() const = 0;
  28.     virtual Rect& getRect() const = 0;
  29.     virtual void getOldAndNew(Rect&) const = 0;
  30. };
  31.  
  32.         // class BouncingObject
  33. class BouncingObject : public ForegroundObject {
  34. public:
  35.     // only has one sprite
  36.     BouncingObject(CIconSprite&, const Rect& whereTo,
  37.         PixelCord xOff =1, PixelCord yOff =1, PixelCord theSlack =3);
  38.     virtual ~BouncingObject() {}
  39.     
  40.     void draw(BufferAccessor&) const;
  41.     void move(BufferAccessor&);
  42.     Rect& getOldRect() const;
  43.     Rect& getRect() const;
  44.     void getOldAndNew(Rect&) const;
  45.  
  46. private:
  47.     CIconSprite& sprite;
  48.     Rect where;
  49.     Rect oldWhere;
  50.     PixelCord xDelta;
  51.     PixelCord yDelta;
  52.     PixelCord slack;
  53. };
  54.  
  55. #endif